{% extends "business/business_base.html" %}
{% import "bootstrap/wtf.html" as wtf %} 
{% block title %}上传车源{% endblock %}
{% block head %} 
{{ super() }}
<link rel="stylesheet" href="{{ url_for('static', filename='css/upload.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datetimepicker.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/city-picker.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2.min.css') }}">
{% endblock %}
{% block page_content %}

{{ super() }}

<h1 class="page-header">上传车源</h1>
<div class="col-md-10">
	<div class="sh-upload-con">
		<ul class="sh-upload-tab">
			<li class="tab-selected" onclick="window.location.href='/business/car/upload/old/'">上传二手车</li>
			<li onclick="window.location.href='/business/car/upload/new/'">上传新车</li>
		</ul>
		<div class="sh-upload-tab-con">
			<div class="upload-tab-list">
				<div class="sh-frame-number sh-car-list">
					<span class="sh-tab-name">车架号：</span>
					<input id="frame_number" type="text" maxlength="17" required>
					<span id='frame_len'class="sh-tab-num">（0/17）</span>
					<span id='sp_frame_number' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-type sh-car-list">
					<span class="sh-tab-name">车型：</span>
					<select id="car_type" class="select2" required>
						{% for k,v in car_type.items() %}
						<option value="{{ k }}">{{ v }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="sh-car-brand sh-car-list">
					<span class="sh-tab-name">品牌：</span>
					<select id="brand" class="select2" required>
						{% for k,v in brand.items() %}
						<option value="{{ k }}">{{ v }}</option>
						{% endfor %}
					</select>
					<input id="model" class="brand-input" type="text" placeholder="请填写具体车型，如大切诺基 SRT 2013款 6.4L SRT8">
					<span id='sp_model' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-appoint sh-car-list">
					<span class="sh-tab-name">指定车型：</span>
					<input id="specific" name="是" type="checkbox"/>
					<span class="car-appoint-tips">是</span>
					<span class="sh-tab-num">（若非指定车型，申请确认后车辆将在15个工作日后交互到客户）</span>
				</div>
				<div class="sh-car-price sh-car-list">
					<span class="sh-tab-name">出售价格：</span>
					<input id="price" class="sh-car-input" type="text" required>
					<span class="sh-car-txt">元</span>
					<span id='sp_price' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-frame-number sh-car-list">
					<span class="sh-tab-name">首次上牌时间：</span>
					<input type="text"  value="2012-05" id="licensing_date" readonly required>
					<span id='sp_licensing_date' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-frame-number sh-car-list" style="position:relative;">
					<span class="sh-tab-name">上牌地：</span>
					<input readonly type="text" id="licensing_place" placeholder="点击从下拉面板中选择省/市" required>
					<span id='sp_licensing_place' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-age sh-car-list">
					<span class="sh-tab-name">车龄：</span>
					<input id="age_of_car" class="sh-car-input" type="text">
					<span class="sh-car-txt">年</span>
					<span id='sp_age_of_car' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-drive sh-car-list">
					<span class="sh-tab-name">行驶里程数：</span>
					<input id="mileage" class="sh-car-input" type="text" required>
					<span class="sh-car-txt">公里</span>
					<span id='sp_mileage' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-speed sh-car-list">
					<span class="sh-tab-name">变速箱类型：</span>
					<select id='gearbox' required>
						{% for k,v in gearbox.items() %}
						<option value="{{ k }}">{{ v }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="sh-car-list">
					<span class="sh-tab-name">排放标准：</span>
					<select id="standard" required>
						{% for k,v in standard.items() %}
						<option value="{{ k }}">{{ v }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="sh-car-sit sh-car-list">
					<span class="sh-tab-name">排量：</span>
					<input id="displacement" class="sh-car-input" type="text" required>
					<span class="sh-car-txt">L</span>
					<span id='sp_displacement' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-list">
					<span class="sh-tab-name">颜色：</span>
					<select id="color" required>
						{% for k,v in color.items() %}
						<option value="{{ k }}">{{ v }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="sh-car-sit sh-car-list">
					<span class="sh-tab-name">座位数：</span>
					<input id="seat" class="sh-car-input" type="text" required>
					<span class="sh-car-txt">座</span>
					<span id='sp_seat' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-supplement sh-car-list">
					<span class="sh-tab-name">补充说明：</span>
					<textarea id="desc"></textarea>
					<span id='sp_desc' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-frame-number sh-car-list">
					<span class="sh-tab-name">年检：</span>
					<input type="text"  value="2012-05" id="annual" readonly required>
					<span id='sp_annual' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-frame-number sh-car-list">
					<span class="sh-tab-name">交强险：</span>
					<input type="text"  value="2012-05" id="compulsory" readonly required>
					<span id='sp_compulsory' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-frame-number sh-car-list">
					<span class="sh-tab-name">商业险：</span>
					<input type="text" id="commercial" readonly>
					<span class="sh-tab-num">（选填）</span>
				</div>
				<div class="sh-car-list">
					<span class="sh-tab-name">过户次数：</span>
					<input id="transfer" class="sh-car-input" type="text">
					<span class="sh-car-txt">次</span>
					<span id='sp_transfer' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-list">
					<span class="sh-tab-name">联系人：</span>
					<input id="contact" class="sh-car-input" type="text">
					<span id='sp_contact' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="sh-car-list">
					<span class="sh-tab-name">联系电话：</span>
					<input id="phone" class="sh-car-input" type="text">
					<span id='sp_phone' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="row sh-car-list" style="position:relative;">
					<span class="sh-tab-name">看车地址：</span>
					<input id="city" type="text" placeholder="选择省/市" style="display:inline-block" readonly>
					<input id="address" class="sh-car-input" style="margin-left:10px;width:300px;" type="text" placeholder="请填写具体地址">
					<span id='sp_address' class="sh-tab-num" style="background:#FFDAB9;display:none;">请填写该项</span>
				</div>
				<div class="row sh-car-list cleafix">
					<div class="sh-tab-name fl">车辆实拍照片：</div>
					<div class="fl">
						<div id="car-pre" style="width:1000px;"></div>
						<div id="car_pic">
							<a class="upload-btn" id="car_pick" href="#" style="text-decoration:none;">
								<i class="fa fa-plus fa-lg fa-fw"></i><span>选择文件</span>
							</a>
						</div>
					</div>
				</div>
				<div class="row sh-car-list cleafix" >
					<div class="sh-tab-name fl">车辆检测报告：</div>
					<div class="fl">
						<div id="check-pre" style="width:1000px;"></div>
						<div id="check_pic">
							<a class="upload-btn" id="check_pick" href="#" style="text-decoration:none;">
								<i class="fa fa-plus fa-lg fa-fw"></i><span>选择文件</span>
							</a>
						</div>
					</div>
				</div>
				<div class="row sh-car-list cleafix" >
					<div class="sh-tab-name fl">证件实拍：</div>
					<div class="fl">
						<div id="other-pre" style="width:1000px;"></div>
						<div id="other_pic">
							<a class="upload-btn" id="other_pick" href="#" style="text-decoration:none;">
								<i class="fa fa-plus fa-lg fa-fw"></i><span>选择文件</span>
							</a>
						</div>
					</div>
				</div>
				<input id="new" type="hidden" value='0'>
			</div>
			<div>
				<center>
					<button class="btn btn-success" onclick="submit()" >确定上传</button>
				</center>
			</div>
		</div>
	</div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ url_for('static', filename='js/qiniu.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/plupload.full.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.zh-CN.js') }}" charset="UTF-8"></script>
<script src="{{ url_for('static', filename='js/city-picker.data.js') }}"></script>
<script src="{{ url_for('static', filename='js/city-picker.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/select2.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.plupload.queue.js') }}"></script>
<script>

$('#nav_car').attr("class", "active");
$('#CarMenu').addClass("in");
$('#li_upload').css("background", "#E0EEE0");

</script>
<script>

var car_photo = new Array();
var check_photo = new Array();
var other_photo = new Array();

var car_uploader = Qiniu.uploader({
	runtimes: 'html5,flash,html4',      // 上传模式，依次退化
	browse_button: 'car_pick',         // 上传选择的点选按钮，必需
	uptoken_url: '/auth/uptoken/',      // Ajax请求uptoken的Url，强烈建议设置（服务端提供）
	unique_names: false,		    // 默认 false，key为文件名。若开启该选项，SDK为自动生成上传成功后的key（文件名）。
	save_key: false, 		    // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`，则开启，SDK会忽略对key的处理
	filters: {
		mime_types: [{
				title: "Image files", extensions: "jpg,jpeg,png"
		}]
	},
	domain: 'http://omdcfjxex.bkt.clouddn.com/',   //bucket 域名，下载资源时用到，**必需**
	get_new_uptoken: false,  	    //设置上传文件的时候是否每次都重新获取新的token
	container: 'car_pic',               //上传区域DOM ID，默认是browser_button的父元素，
	max_file_size: '50mb',              // 最大文件体积限制
	flash_swf_url: '/static/js/Moxie.swf',  //引入flash，相对路径
	max_retries: 3,                     // 上传失败最大重试次数
	dragdrop: true,                     // 开启可拖曳上传
	drop_element: 'car_pic',            // 拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
	chunk_size: '4mb',                  // 分块上传时，每块的体积
	auto_start: true,                   // 选择文件后自动上传，若关闭需要自己绑定事件触发上传
	init: {
		'FilesAdded': function(up, files) {
			plupload.each(files, function(file) {
			// 文件添加进队列后，处理相关的事情
			});
		},
		'BeforeUpload': function(up, file) {
      			// 每个文件上传前，处理相关的事情
		        $('#car-pre').append(
                                '<div class="pre" data-pre-id="' + file.id + '"><img src="{{ url_for('static', filename='img/loading.gif') }}" />\
					<div class="pre-title">Loading</div><div class="pre-info"></div></div>');
			},
		'UploadProgress': function(up, file) {
             		// 每个文件上传时，处理相关的事情
		},
		'FileUploaded': function (up, file, info){
			var info = $.parseJSON(info);
			var domain = up.getOption('domain');
			$('.pre[data-pre-id="' + file.id + '"]').attr('data-key', info['key']);
			$('.pre[data-pre-id="' + file.id + '"]').children('img').attr('src', domain + info['key'] + '?imageView2/1/w/176/h/110');
			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-title').text(info['key']);
 			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-info').html("<span>大小:" + 
			(file.size / 1024).toFixed(1) + " KB</span><a class='pre-del' data-key='" + info['key'] + "'><i class='fa fa-trash'></i> 删除</a>");
                        $('.pre-del').bind('click',function () {
                            var key = $(this).data('key');
                            $('div[data-key="' + key + '"]').remove();
			    var index = car_photo.indexOf(key);
			    if(index != -1){
				car_photo.splice(index, 1);
			    }
                        })
			car_photo.push(info['key']);
                    },
		'Error': function(up, err, errTip) {
			//上传出错时，处理相关的事情
		},
		'UploadComplete': function() {
            	//队列文件处理完毕后，处理相关的事情
		},
		'Key': function (up, file) {
                        // 若想在前端对每个文件的key进行个性化处理，可以配置该函数
                        // 该配置必须要在 unique_names: false , save_key: false 时才生效
			ext = Qiniu.getFileExtension(file.name);
			file_name = (new Date()).valueOf();
			var key = file_name + "." + ext;
			// do something with key here
			return key;
		}
    }
});

var check_uploader = Qiniu.uploader({
	runtimes: 'html5,flash,html4',      // 上传模式，依次退化
	browse_button: 'check_pick',         // 上传选择的点选按钮，必需
	uptoken_url: '/auth/uptoken/',      // Ajax请求uptoken的Url，强烈建议设置（服务端提供）
	unique_names: false,		    // 默认 false，key为文件名。若开启该选项，SDK为自动生成上传成功后的key（文件名）。
	save_key: false, 		    // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`，则开启，SDK会忽略对key的处理
	filters: {
		mime_types: [{
				title: "Image files", extensions: "jpg,jpeg,png"
		}]
	},
	domain: 'http://omdcfjxex.bkt.clouddn.com/',   //bucket 域名，下载资源时用到，**必需**
	get_new_uptoken: false,  	    //设置上传文件的时候是否每次都重新获取新的token
	container: 'check_pic',               //上传区域DOM ID，默认是browser_button的父元素，
	max_file_size: '50mb',              // 最大文件体积限制
	flash_swf_url: '/static/js/Moxie.swf',  //引入flash，相对路径
	max_retries: 3,                     // 上传失败最大重试次数
	dragdrop: true,                     // 开启可拖曳上传
	drop_element: 'check_pic',            // 拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
	chunk_size: '4mb',                  // 分块上传时，每块的体积
	auto_start: true,                   // 选择文件后自动上传，若关闭需要自己绑定事件触发上传
	init: {
		'FilesAdded': function(up, files) {
			plupload.each(files, function(file) {
			// 文件添加进队列后，处理相关的事情
			});
		},
		'BeforeUpload': function(up, file) {
      			// 每个文件上传前，处理相关的事情
		        $('#check-pre').append(
                                '<div class="pre" data-pre-id="' + file.id + '"><img src="{{ url_for('static', filename='img/loading.gif') }}" />\
					<div class="pre-title">Loading</div><div class="pre-info"></div></div>');
			},
		'UploadProgress': function(up, file) {
             		// 每个文件上传时，处理相关的事情
		},
		'FileUploaded': function (up, file, info){
			var info = $.parseJSON(info);
			var domain = up.getOption('domain');
			$('.pre[data-pre-id="' + file.id + '"]').attr('data-key', info['key']);
			$('.pre[data-pre-id="' + file.id + '"]').children('img').attr('src', domain + info['key'] + '?imageView2/1/w/176/h/110');
			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-title').text(info['key']);
 			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-info').html("<span>大小:" + 
			(file.size / 1024).toFixed(1) + " KB</span><a class='pre-del' data-key='" + info['key'] + "'><i class='fa fa-trash'></i> 删除</a>");
                        $('.pre-del').bind('click',function () {
                            var key = $(this).data('key');
                            $('div[data-key="' + key + '"]').remove();
			    var index = check_photo.indexOf(key);
			    if(index != -1){
				check_photo.pop(index);
			    }
                        })
			check_photo.push(info['key']);
                    },
		'Error': function(up, err, errTip) {
			//上传出错时，处理相关的事情
		},
		'UploadComplete': function() {
            	//队列文件处理完毕后，处理相关的事情
		},
		'Key': function (up, file) {
                        // 若想在前端对每个文件的key进行个性化处理，可以配置该函数
                        // 该配置必须要在 unique_names: false , save_key: false 时才生效
			ext = Qiniu.getFileExtension(file.name);
			file_name = (new Date()).valueOf();
			var key = file_name + "." + ext;
			// do something with key here
			return key;
		}
    }
});

var other_uploader = Qiniu.uploader({
	runtimes: 'html5,flash,html4',      // 上传模式，依次退化
	browse_button: 'other_pick',        // 上传选择的点选按钮，必需
	uptoken_url: '/auth/uptoken/',      // Ajax请求uptoken的Url，强烈建议设置（服务端提供）
	unique_names: false,		    // 默认 false，key为文件名。若开启该选项，SDK为自动生成上传成功后的key（文件名）。
	save_key: false, 		    // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`，则开启，SDK会忽略对key的处理
	filters: {
		mime_types: [{
				title: "Image files", extensions: "jpg,jpeg,png"
		}]
	},
	domain: 'http://omdcfjxex.bkt.clouddn.com/',   //bucket 域名，下载资源时用到，**必需**
	get_new_uptoken: false,  	    //设置上传文件的时候是否每次都重新获取新的token
	container: 'other_pic',             //上传区域DOM ID，默认是browser_button的父元素，
	max_file_size: '50mb',              // 最大文件体积限制
	flash_swf_url: '/static/js/Moxie.swf',  //引入flash，相对路径
	max_retries: 3,                     // 上传失败最大重试次数
	dragdrop: true,                     // 开启可拖曳上传
	drop_element: 'other_pic',          // 拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
	chunk_size: '4mb',                  // 分块上传时，每块的体积
	auto_start: true,                   // 选择文件后自动上传，若关闭需要自己绑定事件触发上传
	init: {
		'FilesAdded': function(up, files) {
			plupload.each(files, function(file) {
			// 文件添加进队列后，处理相关的事情
			});
		},
		'BeforeUpload': function(up, file) {
      			// 每个文件上传前，处理相关的事情
		        $('#other-pre').append(
                                '<div class="pre" data-pre-id="' + file.id + '"><img src="{{ url_for('static', filename='img/loading.gif') }}" />\
					<div class="pre-title">Loading</div><div class="pre-info"></div></div>');
			},
		'UploadProgress': function(up, file) {
             		// 每个文件上传时，处理相关的事情
		},
		'FileUploaded': function (up, file, info){
			var info = $.parseJSON(info);
			var domain = up.getOption('domain');
			$('.pre[data-pre-id="' + file.id + '"]').attr('data-key', info['key']);
			$('.pre[data-pre-id="' + file.id + '"]').children('img').attr('src', domain + info['key'] + '?imageView2/1/w/176/h/110');
			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-title').text(info['key']);
 			$('.pre[data-pre-id="' + file.id + '"]').children('.pre-info').html("<span>大小:" + 
			(file.size / 1024).toFixed(1) + " KB</span><a class='pre-del' data-key='" + info['key'] + "'><i class='fa fa-trash'></i> 删除</a>");
                        $('.pre-del').bind('click',function () {
                            var key = $(this).data('key');
                            $('div[data-key="' + key + '"]').remove();
			    var index = other_photo.indexOf(key);
			    if(index != -1){
				other_photo.pop(index);
			    }
                        })
			other_photo.push(info['key']);
                    },
		'Error': function(up, err, errTip) {
			//上传出错时，处理相关的事情
		},
		'UploadComplete': function() {
            	//队列文件处理完毕后，处理相关的事情
		},
		'Key': function (up, file) {
                        // 若想在前端对每个文件的key进行个性化处理，可以配置该函数
                        // 该配置必须要在 unique_names: false , save_key: false 时才生效
			ext = Qiniu.getFileExtension(file.name);
			file_name = (new Date()).valueOf();
			var key = file_name + "." + ext;
			// do something with key here
			return key;
		}
    }
});

</script>
<script>
var InitPicker = function(name){
	
	$('#'+name).datetimepicker({
		format: 'yyyy-mm',
		language: 'zh-CN',
		autoclose: true,
		minView: 3,
		startView: 3,
	});
}

$(document).ready(function() {
	
	$(".select2").select2();
	$("#car_type").select2({
		minimumResultsForSearch: Infinity,
	});
	InitPicker('licensing_date');
	InitPicker('annual');
	InitPicker('compulsory');
	InitPicker('commercial');
	$('#licensing_place').citypicker({
		level: 'city',
	});
	$('#city').citypicker({
		level: 'city',
		simple: true,
	});
	$('#MsgModal').on('hidden.bs.modal', function () {
		if(state === 0){
			window.location.reload();
		}
	});

	$('#frame_number').bind('input propertychange', function() {
		$('#frame_len').html("(" + $(this).val().length + "/17)");
	});

});

</script>
<script>
var state = -1;

var submit = function(){
	data = {};
	data['frame_number'] = $('#frame_number').val();
	data['car_type'] = $('#car_type').val();
	data['brand'] = $('#brand').val();
	data['model'] = $('#model').val();
	data['specific'] = $('#specific').is(':checked');
	data['price'] = $('#price').val();
	data['licensing_date'] = $('#licensing_date').val();
	data['licensing_place'] = $('#licensing_place').val();
	data['age_of_car'] = $('#age_of_car').val();
	data['mileage'] = $('#mileage').val();
	data['gearbox'] = $('#gearbox').val();
	data['standard'] = $('#standard').val();
	data['displacement'] = $('#displacement').val();
	data['color'] = $('#color').val();
	data['seat'] = $('#seat').val();
	data['desc'] = $('#desc').val();
	data['annual'] = $('#annual').val();
	data['compulsory'] = $('#compulsory').val();
	data['commercial'] = $('#commercial').val();
	data['transfer'] = $('#transfer').val();
	data['contact'] = $('#contact').val();
	data['phone'] = $('#phone').val();
	data['city'] = $('#city').val();
	data['address'] = $('#address').val();
	data['submit'] = 'True';
	data['car_photo'] = JSON.stringify(car_photo);
	data['check_photo'] = JSON.stringify(check_photo);
	data['other_photo'] = JSON.stringify(other_photo);
	data['new'] = $('#new').val();
	for(k in data){
		$('#sp_'+k).hide();
	}
	var unfilled = false;
	for(k in data){
		if(data[k] === "" && k != "commercial"){
			unfilled = true;
			if(k==="city"){
				$('#sp_address').show();
			}
			else{
				$('#sp_'+k).show();
			}
		}
	}
	if(unfilled){
		$('#msg').html("上传失败，请将信息填写完整");
		$('#msg_icon').removeAttr('class');
		$('#msg_icon').attr('class', 'glyphicon glyphicon-remove-sign');
		$('#MsgModal').modal();
		return;
	}
	if($('#frame_number').val().length!=17){
		$('#msg').html("上传失败，请填写正确的车架号");
		$('#msg_icon').removeAttr('class');
		$('#msg_icon').attr('class', 'glyphicon glyphicon-remove-sign');
		$('#MsgModal').modal();
		return;
	}
	$.ajax({
		url: "/business/car/upload/old/",	
		type: "POST",
		data: data,
		dataType:"text",
		success: function(data) {
			json = eval("("+data+")");
			state = json.state;
	                if(json.state === 0){
				$('#msg').html("上传成功");
				$('#msg_icon').removeAttr('class');
				$('#msg_icon').attr('class', 'glyphicon glyphicon-ok-sign');
	                }
			else{
				$('#msg').html("上传失败，" + json.msg);
				$('#msg_icon').removeAttr('class');
				$('#msg_icon').attr('class', 'glyphicon glyphicon-remove-sign');
			}
			$('#MsgModal').modal();
		},
		error: state = -1,
	});
}

</script>
{% endblock %}
